﻿import Taro, { Component } from '@tarojs/taro'
import { Swiper, SwiperItem, Image, View, Text ,RichText } from '@tarojs/components'
import qunimg from '../../assets/images/A6984900727459logo.png'
import CommonJs from '../../utils/common'
import '../../assets/common.scss'
import './my.scss'

export default class Goodshearder extends Component {
 constructor(props) {
    super(props);
    this.state = {
      order:{
      	unpaidNum:0,
      	deliveredNum:0,
      	goodsReceivedNum:0
      },
      isId:0
    }
  }

  componentWillMount () {
    //Taro.setNavigationBarTitle({title:"商品订单"}) 
    this.ischange();
  }

  opens(url,type){
    this.props.onHandOpen(url)
  }
  ischange(){
    var _this = this
    const mallNav = this.props.mallNav
    if (mallNav == 'UC') {
      _this.state.isId = 8
    }else if (mallNav == 'WUC'){
      _this.state.isId = 6
    }else{
      _this.state.isId = 1
    }
    _this.getright(this.state.isId)
  }
  getright(id){
  	var url='/order/papi/v1.9/order/statusNum/'+ id 
  	var _this=this
  	CommonJs.ajaxRequest(url,'','GET',function(res){
		_this.setState({
	      order:res.data
	    })
  	},"wfw")
  }
  render () {
    const navindex = this.props.porpNav
    // console.log(JSON.stringify(this.state.par))
    // console.log(JSON.stringify(navindex))
    const order = this.state.order
    return (
      <View className='goodsorder-title'>
        <View className={navindex=='UNPAID'? 'title activer':'title'} onClick={this.opens.bind(this,'UNPAID')} >
              <Text className='ddtext'>未付款</Text>
          <View className="goods-right" style={order.unpaidNum!=0?"":"display:none"}>{order.unpaidNum}</View>
        </View>
        <View className={navindex=='PAID'?'title activer':'title'} onClick={this.opens.bind(this,'PAID')}>
            <Text className='ddtext'>待出库</Text>
            <View className="goods-right" style={order.deliveredNum!=0?"":"display:none"}>{order.deliveredNum}</View>
        </View>
        <View className={navindex=='GOODS_RECEIVED'?'title activer':'title'} onClick={this.opens.bind(this,'GOODS_RECEIVED')}>
            <Text className='ddtext'>待确认</Text>
            <View className="goods-right" style={order.goodsReceivedNum!=0?"":"display:none"}>{order.goodsReceivedNum}</View>
        </View>
        
        <Text className={navindex=='REFUND'?'title activer':'title'} onClick={this.opens.bind(this,'REFUND')}>退款</Text>
		<Text className={navindex=='CANCEL'?'title activer':'title'} onClick={this.opens.bind(this,'CANCEL')}>取消</Text>
        <Text className={navindex=='COMPLETED'?'title activer':'title'} onClick={this.opens.bind(this,'COMPLETED')}>完成</Text>
      </View>
    )
  }
}